import 'package:cbec_app/generated/json/base/json_convert_content.dart';
import 'package:cbec_app/pages/member/entity/vip_card_item_entity.dart';

VipCardItemEntity $VipCardItemEntityFromJson(Map<String, dynamic> json) {
  final VipCardItemEntity vipCardItemEntity = VipCardItemEntity();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    vipCardItemEntity.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    vipCardItemEntity.name = name;
  }
  final int? receiveType = jsonConvert.convert<int>(json['receiveType']);
  if (receiveType != null) {
    vipCardItemEntity.receiveType = receiveType;
  }
  final int? backgroundType = jsonConvert.convert<int>(json['backgroundType']);
  if (backgroundType != null) {
    vipCardItemEntity.backgroundType = backgroundType;
  }
  final String? backgroundColor = jsonConvert.convert<String>(json['backgroundColor']);
  if (backgroundColor != null) {
    vipCardItemEntity.backgroundColor = backgroundColor;
  }
  final String? backgroundImage = jsonConvert.convert<String>(json['backgroundImage']);
  if (backgroundImage != null) {
    vipCardItemEntity.backgroundImage = backgroundImage;
  }
  final String? terms = jsonConvert.convert<String>(json['terms']);
  if (terms != null) {
    vipCardItemEntity.terms = terms;
  }
  final String? validityDate = jsonConvert.convert<String>(json['validityDate']);
  if (validityDate != null) {
    vipCardItemEntity.validityDate = validityDate;
  }
  final String? equity = jsonConvert.convert<String>(json['equity']);
  if (equity != null) {
    vipCardItemEntity.equity = equity;
  }
  final String? equityShipping = jsonConvert.convert<String>(json['equityShipping']);
  if (equityShipping != null) {
    vipCardItemEntity.equityShipping = equityShipping;
  }
  final String? equityBuy = jsonConvert.convert<String>(json['equityBuy']);
  if (equityBuy != null) {
    vipCardItemEntity.equityBuy = equityBuy;
  }
  final String? equityGiftPak = jsonConvert.convert<String>(json['equityGiftPak']);
  if (equityGiftPak != null) {
    vipCardItemEntity.equityGiftPak = equityGiftPak;
  }
  final List<VipCardItemBuyList>? buyList = (json['buyList'] as List<dynamic>?)?.map((e) => jsonConvert.convert<VipCardItemBuyList>(e) as VipCardItemBuyList).toList();
  if (buyList != null) {
    vipCardItemEntity.buyList = buyList;
  }
  return vipCardItemEntity;
}

Map<String, dynamic> $VipCardItemEntityToJson(VipCardItemEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['receiveType'] = entity.receiveType;
  data['backgroundType'] = entity.backgroundType;
  data['backgroundColor'] = entity.backgroundColor;
  data['backgroundImage'] = entity.backgroundImage;
  data['terms'] = entity.terms;
  data['validityDate'] = entity.validityDate;
  data['equity'] = entity.equity;
  data['equityShipping'] = entity.equityShipping;
  data['equityBuy'] = entity.equityBuy;
  data['equityGiftPak'] = entity.equityGiftPak;
  data['buyList'] = entity.buyList?.map((v) => v.toJson()).toList();
  return data;
}

extension VipCardItemEntityExtension on VipCardItemEntity {
  VipCardItemEntity copyWith({
    String? id,
    String? name,
    int? receiveType,
    int? backgroundType,
    String? backgroundColor,
    String? backgroundImage,
    String? terms,
    String? validityDate,
    String? equity,
    String? equityShipping,
    String? equityBuy,
    String? equityGiftPak,
    List<VipCardItemBuyList>? buyList,
  }) {
    return VipCardItemEntity()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..receiveType = receiveType ?? this.receiveType
      ..backgroundType = backgroundType ?? this.backgroundType
      ..backgroundColor = backgroundColor ?? this.backgroundColor
      ..backgroundImage = backgroundImage ?? this.backgroundImage
      ..terms = terms ?? this.terms
      ..validityDate = validityDate ?? this.validityDate
      ..equity = equity ?? this.equity
      ..equityShipping = equityShipping ?? this.equityShipping
      ..equityBuy = equityBuy ?? this.equityBuy
      ..equityGiftPak = equityGiftPak ?? this.equityGiftPak
      ..buyList = buyList ?? this.buyList;
  }
}

VipCardItemBuyList $VipCardItemBuyListFromJson(Map<String, dynamic> json) {
  final VipCardItemBuyList vipCardItemBuyList = VipCardItemBuyList();
  final String? userEquityCardId = jsonConvert.convert<String>(json['userEquityCardId']);
  if (userEquityCardId != null) {
    vipCardItemBuyList.userEquityCardId = userEquityCardId;
  }
  final double? price = jsonConvert.convert<double>(json['price']);
  if (price != null) {
    vipCardItemBuyList.price = price;
  }
  final int? type = jsonConvert.convert<int>(json['type']);
  if (type != null) {
    vipCardItemBuyList.type = type;
  }
  final bool? isSelected = jsonConvert.convert<bool>(json['isSelected']);
  if (isSelected != null) {
    vipCardItemBuyList.isSelected = isSelected;
  }
  return vipCardItemBuyList;
}

Map<String, dynamic> $VipCardItemBuyListToJson(VipCardItemBuyList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['userEquityCardId'] = entity.userEquityCardId;
  data['price'] = entity.price;
  data['type'] = entity.type;
  data['isSelected'] = entity.isSelected;
  return data;
}

extension VipCardItemBuyListExtension on VipCardItemBuyList {
  VipCardItemBuyList copyWith({
    String? userEquityCardId,
    double? price,
    int? type,
    bool? isSelected,
  }) {
    return VipCardItemBuyList()
      ..userEquityCardId = userEquityCardId ?? this.userEquityCardId
      ..price = price ?? this.price
      ..type = type ?? this.type
      ..isSelected = isSelected ?? this.isSelected;
  }
}
